package com.qf.base.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * projectName: automation
 *
 * @author dongshihao
 * Date:2021/9/26   14:09
 * description: 正则表达式的工具类
 */
public class PatternUtil {


    /**
     * 手机号的正则表达式
     */
    private static Pattern MOBILE_PATTERN = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");


    /**
     * 电子邮箱的验证
     */
    private static Pattern EMAIL_PATTERN = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");



    /**
     * 判断是不是手机号的方法
     */
    public static boolean isMobile(String mobile) {
        Matcher matcher = MOBILE_PATTERN.matcher(mobile);
        return matcher.matches();
    }

    /**
     * 判断是不是邮箱的的方法
     */
    public static boolean isEmail(String email) {
        Matcher matcher = EMAIL_PATTERN.matcher(email);
        return matcher.matches();
    }

    public static void main(String[] args) {
        System.out.println(isMobile("15554557080"));
        System.out.println(isEmail("3090930041@qq.com"));

    }
}
